//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <bsp.h>
#include <multiboot.h>
#include <mmu.h>
#include <init.h>
#include <8254.h>

STATIC DECL_CODEINIT void ParseBootCommandLine()
{
}

DECL_ASMLINKAGE DECL_CODEINIT void BspStartup(
    uint_t uMagic, multiboot_info_t *pMultibootInfo)
{
    // Setup
    KrnSetup(KERNEL_PHYSBASE, KERNEL_IMAGEPHYSBASE, 0, 0, 0, 0);

    // Check arguments
    assert(MULTIBOOT_MAGIC == uMagic);

    // Initialize
    InitBootModules();

    ParseBootCommandLine();

    InitMemoryZones(pMultibootInfo);

    InitConsole();

    InitPIC();

    InitPIT();

    if (!KrnInitialize()) {
        BspHalt();
    }

    KrnStartup();

    assert0msg("Kernel startup failed");
}

BspGlobals bsp = {
    "Intel 486+",             // *szCpuDescription
    "PC",                     // *szBoardDescription

    KERNEL_PHYSBASE,          // paKernelPhysBase
    KERNEL_IMAGEPHYSBASE,     // paKernelImagePhysBase

    NULL,                     // *pMemoryZones
    0,                        // uNumberOfMemoryZones

    NULL,                     // *pMemoryHoles
    0,                        // uNumberOfMemoryHoles

    0,                        // uDmaPreferredZoneNo
    0,                        // uKernelPreferredZoneNo
    0,                        // uUserPreferredZoneNo

    {0, 0},                   // regionOfInitStack

    NULL,                     // *pBootModules
    0,                        // uNumberOfBootModules
    {0, 0},                   // regionOfBootModules

    NULL,                     // *szBootCommandLine

    0x20,                     // uIrqBase
    16,                       // uNumberOfIrqs

    PIT_Irq,                  // irqOfPIT
    IPL0                      // iplOfPIT
};
